<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<html>
<head>
	<title>收货地址管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function () {

		});

		function page(n, s) {
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
			return false;
		}
	</script>
</head>
<body>
<ul class="nav nav-tabs">
	<li class="active"><a href="${ctx}/shop/address/address/">收货地址列表</a></li>

	<c:if test="${fns:getUser().roleNames.contains('普通用户')}">
	<shiro:hasPermission name="shop:address:address:edit">
	<li><a href="${ctx}/shop/address/address/form">收货地址添加</a></li>
	</shiro:hasPermission>
	</c:if>
	<ul>
		<form:form id="searchForm" modelAttribute="address" action="${ctx}/shop/address/address/" method="post"
				   class="breadcrumb form-search">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		<ul class="ul-form">
			<li><label>用户名称：</label>
				<sys:treeselect id="user" name="user.id" value="${address.user.id}" labelName="user.name"
								labelValue="${address.user.name}"
								title="用户" url="/sys/office/treeData?type=3" cssClass="input-small" allowClear="true"
								notAllowSelectParent="true"/>
			</li>
			<li><label>地址：</label>
				<form:input path="address" htmlEscape="false" maxlength="255" class="input-medium"/>
			</li>
			<li><label>电话号码：</label>
				<form:input path="phone" htmlEscape="false" maxlength="255" class="input-medium"/>
			</li>
			<li class="btns"><input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/></li>
			<li class="clearfix"></li>
		</ul>
		</form:form>
		<sys:message content="${message}"/>
		<table id="contentTable" class="table table-striped table-bordered table-condensed">
			<thead>
			<tr>
				<th>用户名称</th>
				<th>地址</th>
				<th>电话号码</th>
				<th>更新时间</th>
				<th>备注</th>
				<shiro:hasPermission name="shop:address:address:edit">
					<th>操作</th>
				</shiro:hasPermission>
			</tr>
			</thead>
			<tbody>
			<c:forEach items="${page.list}" var="address">
				<tr>
					<td><a href="${ctx}/shop/address/address/form?id=${address.id}">
							${address.user.name}
					</a></td>
					<td>
							${address.address}
					</td>
					<td>
							${address.phone}
					</td>
					<td>
						<fmt:formatDate value="${address.updateDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
					</td>
					<td>
							${address.remarks}
					</td>
					<c:if test="${fns:getUser().roleNames.contains('普通用户')}">
						<shiro:hasPermission name="shop:address:address:edit">
							<td>
								<a href="${ctx}/shop/address/address/form?id=${address.id}">修改</a>
								<a href="${ctx}/shop/address/address/delete?id=${address.id}"
								   onclick="return confirmx('确认要删除该收货地址吗？', this.href)">删除</a>
							</td>
						</shiro:hasPermission>
					</c:if>
					<c:if test="${!(fns:getUser().roleNames.contains('普通用户'))}">
						<shiro:hasPermission name="shop:address:address:edit">
							<td>
								<a href="${ctx}/shop/address/address/form?id=${address.id}">修改</a>
							</td>
						</shiro:hasPermission>
					</c:if>
				</tr>
			</c:forEach>
			</tbody>
		</table>
		<div class="pagination">${page}</div>
</body>
</html>